﻿// Open Source: MIT License (http://www.opensource.org/licenses/mit-license.php)
// Project: YoProgramo.NET (http://code.google.com/p/yoprogramo/)
// Autor: Fabian Figueredo (info@fabianfigueredo.com.ar)
// Blog: blog.yoprogramo.net

using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using Castle.Windsor;
using NHibernate;
using YoProgramo.Domain.Core.Entities;
using YoProgramo.Domain.Core.Interfaces;

namespace YoProgramo.Infrastructure.Data
{
    public class DAOFactory<Tentity, Type, Tid> : IDAOFactory<Tentity, Type, Tid>
    {
        public IDao<Tentity, Type, Tid> Get()
        {
            if (typeof(Type) == typeof(IStory))
                return new DAOStory<Tid>() as IDao<Tentity, Type, Tid>;
            else if (typeof(Type) == typeof(ITag))
                return new DAOTag<Tid>() as IDao<Tentity, Type, Tid>;
            else if (typeof(Type) == typeof(IUser))
                return new DAOUser<Tid>() as IDao<Tentity, Type, Tid>;
            else if (typeof(Type) == typeof(ICategory))
                return new DAOCategory<Tid>() as IDao<Tentity, Type, Tid>;
            else if (typeof(Type) == typeof(IComment))
                return new DAOComment<Tid>() as IDao<Tentity, Type, Tid>;

            else if (typeof(Type) == typeof(IMarkAsSpam<Story>))
                return new DAOMarkAsSpam<Story, Tid>() as IDao<Tentity, Type, Tid>;
            else if (typeof(Type) == typeof(IMarkAsSpam<Comment>))
                return new DAOMarkAsSpam<Comment, Tid>() as IDao<Tentity, Type, Tid>;

            else if (typeof(Type) == typeof(IVisit<Story>))
                return new DAOVisit<Story, Tid>() as IDao<Tentity, Type, Tid>;

            else if (typeof(Type) == typeof(IVote<Story>))
                return new DAOVote<Story, Tid>() as IDao<Tentity, Type, Tid>;
            else if (typeof(Type) == typeof(IVote<Comment>))
                return new DAOVote<Comment, Tid>() as IDao<Tentity, Type, Tid>;

            return null;         
        }

    }
}